package br.ufpe.cin.analysis.plugin.models;

import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.bind.JAXBException;

import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;

import br.ufpe.cin.analysis.plugin.entities.Activity;
import br.ufpe.cin.analysis.plugin.entities.Metric;
import br.ufpe.cin.analysis.plugin.entities.Process;

public class StatisticalBarDataset extends ChartDataset<DefaultStatisticalCategoryDataset> {
	
	
	public StatisticalBarDataset(String xmlFileName) throws JAXBException, IOException
	{
		super(xmlFileName);
	}

	public StatisticalBarDataset(Process process) {
		super(process);
	}
	
	public StatisticalBarDataset(Process process, String xmlFile) {
		super(process, xmlFile);
	}

	public StatisticalBarDataset()
	{
		super();
	}

	@Override
	public void makeJFreeChartDataset() {

		this.setJFreeChartDataset( new DefaultStatisticalCategoryDataset() );

		for( Activity ac : this.getProcess().getActivities() )
		{
			if(ac.getSelected()){
				for( Metric m : ac.getMetrics())
				{
					if(m.getSelected()) this.getJFreeChartDataset().add(m.getValue(), m.getMarginError(), ac.getName(), m.getName());				
				}
			}
		}


	}
	
	
	
	


}
